import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');

@Define.Table({ TableName: 'device' })
export class Device extends EntityObjectType<Device> {
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    name: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        DataLength: 20,
        NotAllowNULL: true
    })
    type: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        DataLength: 20
    })
    status: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    connectMode: 'usb' | 'network';

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        DataLength: 20
    })
    ip: string;

    @Define.Column({
        DataType: Define.DataType.JSON
    })
    extension: DeviceExtension;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    terminalId: string;
}

export const DeviceType = {
    Printer: 'printer',
    KDS: 'kds'
}

export const DeviceStatus = {
    Enable: 'enable',
    Disable: 'disable'
}

export interface DeviceExtension {
    printWidth: string;
    printerMode: 'ticket' | 'label',
    labelWidth: string;
    labelHeight: string;
    repeatTimes: number;
    labelGap: number;
    vid: string;
    pid: string;
    isBeep: boolean;
    feedHeight: number;
    isCut: boolean;
    isMeituan: boolean;
    isEleme: boolean;
    terminalId: string;
    feed: number;
}